package com.gitee.client;

import com.gitee.enums.ResponseEnum;
import com.gitee.exception.UserException;
import com.gitee.sdk.UserSDK;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;

@FeignClient(name = "canteen-wx-user", fallback = UserClient.UserClientFallBack.class)
public interface UserClient {

    @GetMapping("/client/user")
    UserSDK getUserSDK(Integer userId);

    @Component
    class UserClientFallBack implements UserClient {

        @Override
        public UserSDK getUserSDK(Integer userId) {
            throw new UserException(ResponseEnum.ERROR);
        }
    }
}
